<include file="Public/header"/>

		<div id="app">
			<!-- sidebar -->
			<include file="Public/left"/>
			<!-- / sidebar -->
			<div class="app-content">
				<!-- start: TOP NAVBAR -->
				<include file="Public/headernav"/>
				<!-- end: TOP NAVBAR -->
				<div class="main-content" >
					<div class="wrap-content container" id="container">
						<!-- start: PAGE TITLE -->
						<section id="page-title">
							<div class="row">
								<div class="col-sm-8 col-md-offset-4">
									<h1 class="mainTitle">{$msgtitle}</h1>
									<span class="mainDescription">服务信息</span>
								</div>
								
							</div>
						</section>
						<!-- end: PAGE TITLE -->
						<!-- start: YOUR CONTENT HERE -->
<div class="container-fluid container-fullw bg-white">
<form action="" role="form" id="form2" novalidate="novalidate" method="post">
<div class="row">
	<div class="col-md-10 col-md-offset-2">

     <div class="tabbable">
			<ul class="nav nav-tabs tab-padding tab-space-3 tab-blue" id="myTab4">
				<li class="active">
					<a data-toggle="tab" href="#panel_overview">
						服务基本信息
					</a>
				</li>
				<li>
					<a data-toggle="tab" href="#shop_img">
						服务图片
					</a>
				</li>
			</ul>
          <div class="tab-content">
              <div id="panel_overview" class="tab-pane fade  in active">
                    <div class="row">
	                    <div class="col-md-8">


    <div class="form-group">
		<label class="control-label">
			服务名称<span class="symbol required" aria-required="true"></span>
		</label>
		<input type="text" name="goods_name" value="{$data.goods_name}" id="goods_name" placeholder="服务名称" class="form-control">
	</div>
    <div class="form-group">
		<label class="control-label">
			服务广告词
		</label>
		<input type="text" name="goods_jingle" value="{$data.goods_jingle}" id="goods_jingle" placeholder="服务广告词" class="form-control">
	</div>
  
    <div class="form-group">
        <label class="control-label">
            服务主图
        </label> 
        <br>
        <div class="upload_file">
           <label>
         <input type="file" name="head_photo" class="upload_input" id="head_photo" value="" style="display:none;"> 
          <div class="fileinput fileinput-new" data-provides="fileinput">
                <div class="fileinput-new thumbnail" id="show_photo">
                    <img id="head_photo_src" src="{$data.goods_image}" alt="">
                </div>
            </div>
           点击图片上传
        </label>  
                
         </div>          
          <input type="hidden" name="goods_image" id="goods_image" value="{$data.goods_image}">
    </div>
    <div class="form-group">
		<label class="control-label">
			服务价格
		</label>
		<input type="text" name="goods_price" value="{$data.goods_price}" id="goods_price" placeholder="服务价格" class="form-control">
	</div>

	  <div class="form-group">
		<label class="control-label">
			服务分类 <span class="symbol required" aria-required="true"></span>
		</label>
		<select class="form-control" id="goods_class" name="goods_class">
			<option value="">请选择</option>
            <volist name="list" id="vo">
			<option value="{$vo.id}" <if condition="$data.goods_class eq $vo['id']">selected</if> >{$vo.class_name}</option>
				<volist  name="vo['tree']" id='voo'>
				<option value="{$voo.id}" <if condition="$data.goods_class eq $voo['id']">selected</if> >┗━{$voo.class_name}</option>
			    </volist>
		    </volist>
		</select>
	</div>
	 <div class="form-group">
		<label class="control-label">
			消费提示
		</label>
		<div>
			<textarea id="goods_content" name="goods_content"  class=" autosize" data-autosize-on="true" style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 200px;">{$data.goods_content}</textarea>
			 <!-- 加载编辑器的容器 -->
			 
			 <input type="hidden" name="msg2" id="msg2" value="">
		    </div>
	</div>

	 <div class="form-group">
		<label class="control-label">
			服务内容
		</label>
		<div>
			<textarea id="goods_body" name="goods_body"  class=" autosize" data-autosize-on="true" style="overflow: hidden; resize: horizontal; word-wrap: break-word;  width: 100%;  height: 300px;">{$data.goods_body}</textarea>
			 <!-- 加载编辑器的容器 -->
			 
			 <input type="hidden" name="msg" id="msg" value="">
		    </div>
	</div>


	
<div class="form-group">
		<label class="control-label">
			状态
		</label>
		
		 	<div class="clip-radio radio-primary fa-hover Primary">
           <if condition="$data.id gt 0">
			<input type="radio" value="1" name="goods_state" id="id_no" <if condition="$data.goods_state eq 1">checked="checked"</if> >
			<label for="id_no">
				上架
			</label>

			<input type="radio" value="0" name="goods_state" id="id_yes" <if condition="$data.goods_state eq 0">checked="checked"</if> >
			<label for="id_yes">
				下架
			</label>
             <else/>
             <input type="radio" value="1" name="goods_state" id="id_no" checked="checked">
			<label for="id_no">
				上架
			</label>

			<input type="radio" value="0" name="goods_state" id="id_yes"   >
			<label for="id_yes">
				下架
			</label>

			</if>
	

		</div>
	</div>

<div class="form-group">
		<label class="control-label">
			首页推荐 
		</label>
		 <?php if($_SESSION['topadmin'] > 0){?>
		 	<div class="clip-radio radio-primary fa-hover Primary">
           <if condition="$data.id gt 0">
			<input type="radio" value="1" name="is_show_index" id="is_show_index_no1" <if condition="$data.is_show_index eq 1">checked="checked"</if> >
			<label for="is_show_index_no1">
				已推荐
			</label>

			<input type="radio" value="0" name="is_show_index" id="is_show_index_yes1" <if condition="$data.is_show_index eq 0">checked="checked"</if> >
			<label for="is_show_index_yes1">
				未推荐
			</label>
             <else/>
             <input type="radio" value="1" name="is_show_index" id="is_show_index_no1">
			<label for="is_show_index_no1">
				已推荐
			</label>

			<input type="radio" value="0" name="is_show_index" id="is_show_index_yes1" checked="checked"  >
			<label for="is_show_index_yes1">
				未推荐
			</label>

			</if>
			</div>
			<?php }else{ ?>
		   {$data['is_show_index']?'已推荐':'未推荐'}
		  <?php } ?>
		 

		
	</div>

		<div class="form-group">
		<label class="control-label">
			审核状态 
		</label>
		 <?php if($_SESSION['topadmin'] > 0){ ?>
		 	<div class="clip-radio radio-primary fa-hover Primary">
           <if condition="$data.id gt 0">
            <input type="radio" value="1" name="goods_status" id="id_no0" <if condition="$data['goods_status'] === '0'">checked="checked"</if> >
			<label for="id_no0">
				待审核
			</label>

			<input type="radio" value="1" name="goods_status" id="id_no1" <if condition="$data.goods_status eq 1">checked="checked"</if> >
			<label for="id_no1">
				审核通过
			</label>

			<input type="radio" value="2" name="goods_status" id="id_yes1" <if condition="$data.goods_status eq 2">checked="checked"</if> >
			<label for="id_yes1">
				审核不通过
			</label>
             <else/>
             <input type="radio" value="0" name="goods_status" id="id_no0">
			<label for="id_no0">
				待审核
			</label>

             <input type="radio" value="1" name="goods_status" id="id_no1" checked="checked">
			<label for="id_no1">
				审核通过
			</label>

			<input type="radio" value="2" name="goods_status" id="id_yes1"   >
			<label for="id_yes1">
				审核不通过
			</label>

			</if>
		    </div>
	<?php }else{ ?>
			  <if condition="$data['goods_status'] === '0'">
                 待审核
			 <if condition="$data.goods_status eq 1">
			   审核通过
			 <else/>
			    审核不通过({$data.goods_status_des})
			 </if> 	 	
		   
    <?php }  ?>
	</div>

	






                         </div>
                     </div>
              </div>

             


 <div id="shop_img" class="tab-pane fade">
                    <div class="row">
	                    <div class="col-md-8">


 <div class="form-group">
 	
<span class="btn btn-success fileinput-button upload_file">
 <i class="glyphicon glyphicon-plus"></i> <span>上传文件...</span>
	<input type="file" name="files[]" class="upload_input"  id="head_photo_background"  multiple="">
</span>

  </div>
        <div class="form-group">
       
        <br>
        <div class="goods_image_url">
          
       <volist name="data['goods_image_url']" id='vo'>
          <div class="fileinput fileinput-new" data-provides="fileinput">
                <div class="fileinput-new thumbnail" >
                    <img id="head_photo_src_background" src="{$vo}" alt="" >
                     <button type="button" class="btn btn-danger delete delete_img" style="float: left;margin-top: -40px;margin-left: 200px;">
					<i class="glyphicon glyphicon-trash"></i>
					<span>删除</span>
				 </button>
                </div>

				<input type="hidden" name="goods_image_url[]"  class="goods_image_count" value="{$vo}">
          </div>
       </volist>
                 
         </div>          
     
    </div>





                    </div>
         </div>
  </div>
  	






          </div>
</div>

	
	
	
	






</div>
</div>
<div class="row">
<div class="col-md-4">
	<input type="hidden"  value="{$data.id}" name="id">
	<button class="btn btn-primary btn-wide pull-left" type="submit">
		提交 <i class="fa fa-arrow-circle-right"></i>
	</button>
</div>

<div class="col-md-8">
	<p>
		
	</p>
</div>

</div>											
</form>
</div>	


                  





						<!-- end: YOUR CONTENT HERE -->
					</div>
				</div>
			</div>
			<!--  FOOTER and SETTINGS -->
			
           <include file="Public/footer"/>
			<!-- end: FOOTER -->
			<!-- start: OFF-SIDEBAR -->
			
			<!-- end: OFF-SIDEBAR -->
			
		</div>
		<!-- start: MAIN JAVASCRIPTS -->

         <include file="Public/javascript"/>
		
		<!-- end: CLIP-TWO JAVASCRIPTS -->

		<!-- start: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<script src="__PUBLIC__/bootstrap/vendor/ckeditor/ckeditor.js"></script>
		<script src="__PUBLIC__/bootstrap/vendor/ckeditor/adapters/jquery.js"></script>
		<script src="__PUBLIC__/bootstrap/vendor/jquery-validation/jquery.validate.min.js"></script>
		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<!-- start: CLIP-TWO JAVASCRIPTS -->
		<!-- <script src="__PUBLIC__/bootstrap/assets/js/main.js"></script> -->
		<!-- start: JavaScript Event Handlers for this page -->
		<!--<script src="__PUBLIC__/bootstrap/assets/js/form-validation.js"></script>-->

		

		<script src="__PUBLIC__/bootstrap/vendor/artDialog/artDialog.source.js?skin=default"></script>
       <script src="__PUBLIC__/bootstrap/vendor/artDialog/plugins/iframeTools.source.js"></script>

       <script src="__PUBLIC__/bootstrap/vendor/ajaxfileupload/ajaxfileupload.js"></script>
    <!-- 配置文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.config.js"></script>
    <!-- 编辑器源码文件 -->
    <script type="text/javascript" src="__PUBLIC__/ueditor/ueditor.all.js"></script>
    <!-- 实例化编辑器 -->
    <script type="text/javascript">
        var ue = UE.getEditor('goods_body');
    </script>
 <script type="text/javascript">
        var ue2 = UE.getEditor('goods_content');
    </script>

  <script type="text/javascript">
       jQuery(document).ready(function() {
				//FormValidator.init();
	jQuery.validator.addMethod("get_param_value", function(value) {
		var ret =true;
		ret=ue.hasContents();
	  return ret;   
	});

});
    </script>   
		<!-- end: JAVASCRIPTS REQUIRED FOR THIS PAGE ONLY -->
		<!-- start: CLIP-TWO JAVASCRIPTS -->
		<!-- <script src="__PUBLIC__/bootstrap/assets/js/main.js"></script> -->
		<!-- start: JavaScript Event Handlers for this page -->
		<!--<script src="__PUBLIC__/bootstrap/assets/js/form-validation.js"></script>-->

{//新增}
	<script>
jQuery(document).ready(function() {
				//FormValidator.init();

	$("#form2").validate({
	  rules: {
	   goods_name:"required",
	   goods_image:"required",
	   goods_price:{
	   	required:true,
	   	number:true,
	   	min:0
	   },
	   goods_class:"required",
	   msg: "get_param_value"
	  },
	  messages: {
	  goods_name: "请输入服务名称",
	   goods_image: "请上传服务主图",
	   goods_price:{
	   	required:"请输入服务价格",
	   	number:"请输入正确的价格",
	   	min:"请输入正确的价格"
	   },
	   goods_class:"请选择服务分类",
	    msg: "请输入服务内容"
	  }
	  });
	});
		</script>

<script type="text/javascript">
	$(function(){


$("#type").change(function(){
	var val=$(this).val();
	if(val==1){
		$(".type_2").hide();
		$(".type_1").show();
	}else{
		$(".type_1").hide();
		$(".type_2").show();
	}

});
	});

</script>


<script>
	
    $(document).ready(function (e) {
         ///上传商家logo
        $('.upload_file').on('change','.upload_input', function () {
        	var id=$(this).attr('id');
        	if(id =='head_photo'){
        		//咯go 截取
        		 ajaxFileUploadview('head_photo', 'goods_image', "{:U('admin/Imagecat/upload_ajax')}");
        	}else{
        		var goods_length=$(".goods_image_count").length;
        		if(goods_length>=5){
        			alert('图片最多上传5张');
                //  var dialog = art.dialog({title: false, fixed: true, padding: 0});
                 // art.dialog('这是php点点通的教程', function () {alert('你点击确定了')},function(){alert('你点击取消了');});
                   // dialog.lock().time(2).content("");
        		}else{
        			ajaxFileUpload('background',"{:U('admin/Imagecat/upload_ajax')}");
        		}

        		//
        	}
           
        });

        $('.goods_image_url').on('click','.delete_img', function () {
        	if(confirm('您确定删除该图片？')){
              $(this).parents('.fileinput').remove();
        	}
        });

    });


    function show_head(head_file) {

        //插入数据库
        $("#head_photo_src").attr('src', head_file);
        var img = head_file.split('/');
      //  var file = '/' + img[3] + '/' + img[4] + '/' + img[5] + '/' + img[6];
        $("#goods_image").val(head_file);
        //});   

    }
//文件上传带预览
    function ajaxFileUploadview(imgid, hiddenid, url) {

        $.ajaxFileUpload({
                    url: url,
                    secureuri: false,
                    fileElementId: imgid,
                    dataType: 'json',
                    data: {name: 'logan', id: 'id'},
                    success: function (data, status)
                    {
                      
                        if (typeof (data.error) != 'undefined')
                        {
                              
                            if (data.error != '')
                            {
                                var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            } else {

                                var resp = data.msg;
                                if (resp != '0000') {
                                    var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                    dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                                    return false;
                                } else {
                                    
                                    $('#goods_image').val(data.imgurl);

                                    art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
                                        title: '裁剪图片',
                                        width: '800px',
                                        height: '400px'
                                    });

                                    //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                                }




                            }
                        }
                    },
                    error: function (data, status, e)
                    {
                        var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        dialog.time(3).content("<div class='tips'>" + e + "</div>");
                    }
                })

        return false;
    }
  
//文件上传带预览
    function ajaxFileUpload(imgid,  url) {

        $.ajaxFileUpload({
                    url: url,
                    secureuri: false,
                    fileElementId: "head_photo_"+imgid,
                    dataType: 'json',
                    data: {name: 'logan', id: 'id'},
                    success: function (data, status)
                    {
                      
                        if (typeof (data.error) != 'undefined')
                        {
                              
                            if (data.error != '')
                            {
                                var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                            } else {

                                var resp = data.msg;
                                if (resp != '0000') {
                                    var dialog = art.dialog({title: false, fixed: true, padding: 0});
                                    dialog.time(2).content("<div class='tips'>" + data.error + "</div>");
                                    return false;
                                } else {


                               var str_img=' <div class="fileinput fileinput-new" data-provides="fileinput">'
                                 +' <div class="fileinput-new thumbnail" id="show_photo_background">'
                                 +'   <img  src="'+data.imgurl+'" alt="" >'

                                  +' <button type="button" class="btn btn-danger delete delete_img"  style="float: left;margin-top: -40px;margin-left: 200px;">'
				                 +'	<i class="glyphicon glyphicon-trash"></i>'
				                 +'	<span>删除</span>'
				                 +'</button>'

                                 +'</div>'
	                            
				                 +'<input type="hidden" name="goods_image_url[]" id="photo_pic_background" value="'+data.imgurl+'">'
                                 +' </div>';
                                 $('.goods_image_url').append(str_img);
                                  //  $('#photo_pic_'+imgid).val(data.imgurl);
                                  //   $("#head_photo_src_"+imgid).attr('src', );
                                  /*  art.dialog.open("{:U('admin/Imagecat/index')}?img=" + data.imgurl, {
                                        title: '裁剪图片',
                                        width: '800px',
                                        height: '400px'
                                    });*/
                                      
                                    //dialog.time(3).content("<div class='msg-all-succeed'>上传成功！</div>");
                                }




                            }
                        }
                    },
                    error: function (data, status, e)
                    {
                        var dialog = art.dialog({title: false, fixed: true, padding: 0});
                        dialog.time(3).content("<div class='tips'>" + e + "</div>");
                    }
                })

        return false;
    }
</script>		
		<!-- end: JavaScript Event Handlers for this page -->
	</body>
</html>
